﻿using Framework;
using System.Collections.Generic;
using UnityEngine;
namespace Project
{
    public class PlayerDataSingle : ISingeleton
    {
        public static PlayerDataSingle Intacne => Singleton<PlayerDataSingle>.Instance;

        private float hp = 100;
        public float HP
        {
            get => hp;
            set
            {
                if (hp == value) return;
                EventCenter.GetInstance().EventTrigger("HPChangeEvent");
                hp = value;
            }
        }
        // 侵蚀度
        private float erodibility;
        public float Eodibility
        {
            get => erodibility;
            set
            {
                if (erodibility == value) return;
                EventCenter.GetInstance().EventTrigger("EodibilityChange");
                erodibility = value;
            }
        }

        //玩家武器列表
        private List<WeaponEnum> weaponList = new List<WeaponEnum>();
        public List<WeaponEnum> WeaponList { get => weaponList; }

        //购买武器调用这个方法
        public void AddWeapom(WeaponEnum type)
        {
            if(weaponList.Contains(type) || WeaponDataSingle.Intacne.GetIsBuyWeapom(type)) return;
            if(WeaponDataSingle.Intacne.BuyWeapom(type))
            {
                weaponList.Add(type);
                EventCenter.GetInstance().EventTrigger<WeaponEnum>("AddWeapon", type);
            }
            Debug.Log("添加武器:" + type.ToString());
        }
        public void Init()
        {
            AddWeapom(WeaponEnum.沙鹰手枪);
        }
    }
}